package com.glsc.ngateway.common.base.repo.mysql.gateway.platform.it;


import com.glsc.ngateway.common.base.domain.mysql.gateway.platform.it.ItOperation;
import com.glsc.ngateway.common.api.platform.dto.it.ParamSearchSystemDto;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;


@Repository
public interface ItOperationRepo extends JpaRepository<ItOperation, String> {

    ItOperation findByOpId(String opId);

    @Query(value = "select m from ItOperation m where 1=1 " +
            "and (:opUser is null OR m.opUser = :opUser) " +
            "and (:#{#key.opName} is null or opName like CONCAT('%',:#{#key.opName},'%')) " +
            "and (:#{#key.opStyle} is null or opStyle = :#{#key.opStyle} ) " +
            "and (:#{#key.opBuild} is null or opBuild = :#{#key.opBuild} ) " +
            "and (:#{#key.opSupport} is null or opSupport like CONCAT('%',:#{#key.opSupport},'%')) " +
            "and (:#{#key.status} is null or status = :#{#key.status} ) " +
            "order by m.insertTime desc")
    Page<ItOperation> getByOpUser(Pageable pageable, String opUser, ParamSearchSystemDto key);

}
